﻿using blackhouse.NemoBlog.Business;
using mojoPortal.Web.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace blackhouse.NemoBlog.Web.Controls {
    public partial class SelectBlog : UserControl, ISettingControl {

        private NemoBlogSettings[] allSettings;

        protected override void OnLoad(EventArgs e) {
            base.OnLoad(e);

            if (!this.IsPostBack) {
                this.allSettings = NemoBlogSettings.GetAllSettings();
                this.ddlBlogs.Items.Clear();
                this.ddlBlogs.Items.Add(new ListItem("Wszystkie blogi", "0"));
                foreach (NemoBlogSettings blog in this.allSettings)
                    this.ddlBlogs.Items.Add(new ListItem(blog.BlogTitle, blog.GetInt32("moduleId").ToString()));
            }
        }

        public string GetValue() {
            return Request[this.ddlBlogs.UniqueID];
        }

        public void SetValue(string val) {
            ListItem li = this.ddlBlogs.Items.FindByValue(val);
            if (li != null)
                li.Selected = true;
        }

    }
}